package com.arm.controller.admin.customer;

import com.arm.controller.BaseController;
import com.arm.def.Constant;
import com.arm.module.User;
import com.arm.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;

/**
 * Created by Andrew  on 2017/2/26.
 */
@RestController
@RequestMapping(value = "/admin/customer")
public class AdminCustomerController extends BaseController {
    /*@Autowired
    RedisCache redisCache;*/
    @Autowired
    UserService userService;


    /**
     * 用户列表
     *
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/customerList")
    public ModelAndView getUserList(Integer page,Integer pageSize) {
        ModelAndView mov = new ModelAndView();
        mov.setViewName("admin/customer/customerList");

        if (page == null || page == 0) {
            page = Constant.PAGENUM;
        }
        // 设置每页记录数
        if (pageSize == null || pageSize == 0) {
            pageSize = Constant.PAGESIZENum;
        }
        PageHelper.startPage(page, pageSize);
        List<User> userList = userService.getUserList(new HashMap<String,String>());

        PageInfo<User> pageinfo = new PageInfo<User>(userList);
        mov.addObject("pageinfo", pageinfo);
        return mov;

    }

}
